﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GestionePolveri2
{
    public partial class SplashPage : Form
    {
        public SplashPage()
        {
            InitializeComponent();

            FrameworkLib.Utilities.Singleton<GestionePolveriLib.Cache.LookUpData>.Instance.DataLoaded += new EventHandler(Instance_DataLoaded);

            FrameworkLib.Utilities.Singleton<GestionePolveriLib.Cache.LookUpData>.Instance.LoadLookUps();

            this.progressIndicator1.Start();
        }

        void Instance_DataLoaded(object sender, EventArgs e)
        {
            FrameworkLib.Utilities.Singleton<GestionePolveriLib.Cache.LookUpData>.Instance.CacheLoaded = true;

            this.progressIndicator1.Stop();

            if (this.InvokeRequired)
            {
                MethodInvoker im = new MethodInvoker(CloseLoginForm);
                this.Invoke(im);
            }
            else
            {
                //What you want done goes here
                this.CloseLoginForm();
            }
        }

        private void CloseLoginForm()
        {
            this.Close();
        }
    }
}
